from board import board_info
from fpioa_manager import fm
from maix import GPIO
import time

# 将IO16配置为GPIOHS0
fm.register(16, fm.fpioa.GPIOHS0, force=False)

def test_irq(pin_num):
    print("key", key.value())  #拔起返回0，插上返回1

# 配置GPIOHS0为输入
key=GPIO(GPIO.GPIOHS0, GPIO.IN, GPIO.PULL_NONE)
# 配置GPIOHS0上下边沿中断
key.irq(test_irq, GPIO.IRQ_BOTH, GPIO.WAKEUP_NOT_SUPPORT, 7)

while True:
#for i in range(20):
    #print('key.value(): ', key.value())
    time.sleep_ms(500)

key.disirq()
fm.unregister(board_info.BOOT_KEY)
